import { http } from '@/utils/http.ts'
import type { AddressItem } from '@/types/address'

// 添加收货地址
export const addAddressApi = (data: AddressItem) => {
  return http<{ id: number }>({
    method: 'POST',
    url: '/member/address',
    data,
  })
}

// 获取收货地址列表
export const getAddressListApi = () => {
  return http<AddressItem[]>({
    method: 'GET',
    url: '/member/address',
  })
}

// 获取收货地址详情
export const getAddressDetailApi = (id: string) => {
  return http<AddressItem>({
    method: 'GET',
    url: '/member/address/' + id,
  })
}

// 修改收货地址
export const updateAddressApi = (id: string, data: AddressItem) => {
  return http<{ id: string }>({
    method: 'PUT',
    url: '/member/address/' + id,
    data,
  })
}

// 修改收货地址
export const delAddressApi = (id: string) => {
  return http<{ id: string }>({
    method: 'DELETE',
    url: '/member/address/' + id,
  })
}
